﻿/*----------------------------------------------------------------------------------------
*
*  Copyright 2019, Gao Hai Hui, <fromzeropoint@126.com>.  All rights reserved.
*  https://gitee.com/helloworldghh/xoskit.git
*  Use of this source code is governed by a MIT license
*  that can be found in the License file.
*
----------------------------------------------------------------------------------------*/
#ifndef __XOS_COMPRESS_SRC_ZLIB_IMPL_H__
#define __XOS_COMPRESS_SRC_ZLIB_IMPL_H__

#include "../tools/head.h"

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

namespace xos_compress
{

	class zlib_impl : public xos_stl::mem_item< xos::release_impl< zlib_impl >, thread_lock >,
		public i_compress
	{
    public:
        typedef xos::release_impl< zlib_impl > T;

    public:
        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        //

        static int get_addr( POOL *** pppPool, LIST *** pppList );

    public:
		zlib_impl();
		~zlib_impl();

    protected:
        void * m_pStream;
        bool m_bInitStream;
        bool m_bCompress;

	public:
		int un_compress( char * lpszDest, int nDestLen, int * lpnDestLen, const char * lpszSrc, int nSrcLen );
		int compress( char * lpszDest, int nDestLen, int * lpnDestLen, const char * lpszSrc, int nSrcLen, bool bLast );
        int un_compress( xos_box::i_buf * pDestBuf, xos_box::i_buf * pSrcBuf );
		int compress( xos_box::i_buf * pDestBuf, xos_box::i_buf * pSrcBuf, bool bLast );
        int un_compress( xos_box::i_list * pDestList, xos_box::i_list * pSrcList );
        int compress( xos_box::i_list * pDestList, xos_box::i_list * pSrcList );

	public:
		int init();
		int term();
	};
}

#endif // __XOS_COMPRESS_SRC_ZLIB_IMPL_H__
